#include "test_sys.h"
#include "cm_uart.h"
#include "cm_demo_uart.h"
#include "limits.h"

void cm_test_sys_operation(unsigned char *cmd[],int len)
{
    if (0 == strcmp("SN",cmd[2]))
    {
        char* sn = malloc(30);
        int32_t sys_get_sn = cm_sys_get_sn(sn);
        cm_demo_printf("sys cm_sys_get_sn ret:%d\n",sys_get_sn);
        OCTEST_FUNC_EXPECT_EQUAL_INT32(0,sys_get_sn,cm_sys_get_sn);
        cm_demo_printf("sn:%s\n",sn);
        free(sn);

    }else if(0 == strcmp("IMEI",cmd[2]))
    {
        char buf[30] = {0};
        int32_t sys_get_imei = cm_sys_get_imei(buf);
        cm_demo_printf("sys cm_sys_get_imei ret:%d\n",sys_get_imei); 
        OCTEST_FUNC_EXPECT_EQUAL_INT32(0,sys_get_imei,cm_sys_get_imei);
        cm_demo_printf("imei:%s\n",buf);
    }else if(0 == strcmp("CM_VER",cmd[2]))
    {
        char buf[64] = {0};
        int32_t sys_get_cm_ver = cm_sys_get_cm_ver(buf, 64);
        cm_demo_printf("sys cm_sys_get_cm_ver ret:%d\n",sys_get_cm_ver);
        OCTEST_FUNC_EXPECT_GREATER_OR_EQUAL_INT32(0,sys_get_cm_ver,cm_sys_get_cm_ver);
        cm_demo_printf("cm_ver:%s\n",buf);
    }
    // else if(0 == strcmp("BASE_VER",cmd[2]))
    // {
    //     char buf[64] = {0};
    //     cm_demo_printf("sys cm_sys_get_cm_ver ret:%d\n", cm_sys_get_base_ver(buf, 64));
    //     cm_demo_printf("base_ver:%s\n",buf);
    // }else if(0 == strcmp("STORAGE_STATS",cmd[2]))
    // {
    //     cm_storage_stats_t stats = {0};
    //     cm_demo_printf("sys cm_sys_get_storage_stats ret:%d\n",cm_sys_get_storage_stats(&stats));
    //     cm_demo_printf("stats.flash_total_size:%d, stats.flash_remain:%d, stats.ram_total_size:%d, stats.ram_remain:%d\n",stats.flash_total_size,stats.flash_remain,stats.ram_total_size,stats.ram_remain);
    // }
    else if(0 == strcmp("LOG_PRINT",cmd[2]))
    {
        int a[10] = {0};
        cm_log_printf(0, "cm_test_log_printf:%d,%s,%p,%a,%e,%g,%#x",123,"one",a,302.2654,1002.369,1002.369,100);
    }
    else if(0 == strcmp("DEMO_PRINT",cmd[2]))
    {
        int a[10] = {0};
        cm_demo_printf("cm_demo_printf:%%lld-%lld,%%d-%d,%%lf-%lf,%%s-%s,%%p-%p,%%a-%a,%%e-%e,%%g-%g,%%#x-%#x",LLONG_MAX,123,5986.147658,"one",a,302.2654,1002.369,1002.369,100);
    }
    // else if(0 == strcmp("TIME_ZONE",cmd[2]))
    // {
    //     cm_demo_printf("cm_sys_get_timezone ret:%d\n",cm_sys_get_timezone());
    // }
    // else if(0 == strcmp("EPOCH_SEC",cmd[2]))
    // {
    //     cm_demo_printf("cm_sys_get_epoch_sec ret:%d\n", cm_sys_get_epoch_sec());
    // }
    else{
        cm_demo_printf("param error!\n");
    }
}